<template>
   <current-login></current-login>
</template>
<script>
export default {
  name: 'login-index',
  beforeCreate: function () {
    let flag = this.$store.state.oemObj.oemFlag
    let isOem = this.$store.state.isOem
    if (flag === 'login_gdlt') {  //  根据 flag 和 isoem 判断是否是广东联通
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        // hm.src = "https://hm.baidu.com/hm.js?9f5485532dca6ced25f7ca6f893212f1";    //   测试
        hm.src = "https://hm.baidu.com/hm.js?eabb91d5817bba548efd8313db2eff56";    //  正式
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
      })();
      console.log(window._hmt)
    } else {
      var _hmt = _hmt || [];
      (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?9739a0534948653ebcefb85556c366b5";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
      console.log(window._hmt)
    }
    let currentUrl = window.location.href
    let arr = ['kf.7moor.com', 'kf7.7moor.com', 'ykf.7moor.com']
    let is7moor = false
    for (let i = 0; i < arr.length; i++) {
      if (currentUrl.indexOf(arr[i]) > -1) {
        is7moor = true
        break
      }
    }
    if (flag === '' || (is7moor && !isOem)) {
      this.$options.components.currentLogin = require('./login-kf.vue').default
    } else if (flag === 'error') {
      this.$options.components.currentLogin = require('./login-error.vue').default
    } else {
      try {
        this.$options.components.currentLogin = require('./oem/' + flag + '/login.vue').default
      } catch (e) {
        this.$options.components.currentLogin = require('./login-error.vue').default
        window.alert(this.$t('oem.noPage'))
      }
    }
  }
}
</script>
